package hongvt.quanlynhanvien.adapter;

import hongvt.quanlynhanvien.R;
import hongvt.quanlynhanvien.R.id;
import hongvt.quanlynhanvien.R.layout;
import hongvt.quanlynhanvien.model.FinanceReport;
import hongvt.quanlynhanvien.model.Timekeeping;

import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SalaryReportAdapter extends BaseAdapter {
	Context context;
	List<FinanceReport> items;

	public SalaryReportAdapter(Context context, List<FinanceReport> items) {
		this.context = context;
		this.items = items;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (convertView == null) {

			LayoutInflater inflater = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

			convertView = inflater.inflate(R.layout.layout_salary_report, null,
					false);
		}

		FinanceReport p = getItem(position);

		TextView nameTv = (TextView) convertView.findViewById(R.id.tv_name);
		TextView salaryTv = (TextView) convertView.findViewById(R.id.tv_salary);
		TextView bonusTv = (TextView) convertView.findViewById(R.id.tv_bonus);

		nameTv.setText(p.getEmpName());
		salaryTv.setText(String.valueOf(p.getSalary()));
		bonusTv.setText(String.valueOf(p.getBonus()));

		return convertView;
	}

	@Override
	public int getCount() {
		if (items != null) {
			return items.size();
		}

		return 0;
	}

	@Override
	public FinanceReport getItem(int position) {
		// TODO Auto-generated method stub
		return items.get(position);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}
}
